//
//  XMPointsBindViewController.m
//  XunMi
//
//  Created by MacBook on 2024/3/14.
//  Copyright © 2024 TieZhu. All rights reserved.
//

#import "XMPointsBindViewController.h"

@interface XMPointsBindViewController ()
@property (weak, nonatomic) IBOutlet UITextField *textField;

@end

@implementation XMPointsBindViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = kHEX(@"F2F2F2");
    self.navView.backgroundColor = kHEX(@"F2F2F2");
    [self.navLeft2Btn setTitle:@"绑定支付宝账号" forState:UIControlStateNormal];
}

- (IBAction)sureAction:(UIButton *)sender {
    if ([XMUtil isBlankString:self.textField.text]) {
        [MBProgressHUD showHUDMsg:self.textField.placeholder toView:kWindow];
        return;
    }
    
    [self.textField resignFirstResponder];
    [MBProgressHUD showHUDActivityMsg:nil  toView:kWindow];
    NSMutableDictionary *dic = @{
        @"account": self.textField.text
    }.mutableCopy;
    
    [YHNetworkManager.sharedInstance postWithUrl:@"api/user/alipay/update" parameters:dic completeBlock:^(XMResponseTip * _Nonnull tip, id  _Nullable result) {
        if (tip.success) {
            [MBProgressHUD hideHUD];
            [MBProgressHUD showHUDMsg:@"支付宝绑定成功" toView:kWindow];
            [self backAction];
        }
    }];
    
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    if (self.backBlock) {
        self.backBlock();
    }
}

@end
